package org.zl.mybatis.use.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger配置
 * @author ben
 * @date 2021-11-25 20:37:54 CST
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

	private String appBasePackage = "org.zl.mybatis.use";
	
	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.select()
				// 搜索包名：本项目基础package
				.apis(RequestHandlerSelectors.basePackage(appBasePackage))
				// 包名下的任何路径
				.paths(PathSelectors.any())
				.build();
	}
	
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				// 标题
				.title("S.B.项目")
				// 描述
				.description("Swagger使用")
				// 版本
				.version("1.0.0")
				// 联系人信息
				.contact(new Contact("ben", "http://localhost:10000", "ben@localhost"))
				.build();
	}
	
}
